
//获取当天，或之前的某天
export function getDate(lastLength=0){
    let date=new Date();
    let year = date.getFullYear();
    let month = date.getMonth()+1;    
    let day = date.getDate();
    let nowDate = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
    if(lastLength==0){
        return nowDate;
    }
  //获取30天前得日期
  let lastDate = new Date(date - 1000 * 60 * 60 * 24 * lastLength);//最后30天可以更改，意义：是获取多少天前的时间
  let lastY = lastDate.getFullYear();
  let lastM = lastDate.getMonth()+1;
  let lastD = lastDate.getDate();
  return lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-"+(lastD < 10 ? "0" + lastD : lastD);//得到30天前的时间
}
